package com.examples.master;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import com.examples.calendar.CalendarView;
import com.examples.calendar.item.CalendarMain;
import com.examples.colordialogue.ColourBasic;
import com.examples.combobox.ComboBasic;
import com.examples.combobox.KeyListenerInCombo;
import com.examples.composite.CompositeEnhanced;
import com.examples.composite.PaintComposite;
import com.examples.composite.StringPrompt;
import com.examples.control.ControlBasic;
import com.examples.control.MultiLineText;
import com.examples.controls.concepts.EnablingBasic;
import com.examples.controls.concepts.MoveBasic;
import com.examples.controls.concepts.ResizeEvent;
import com.examples.coolbar.CoolItemBasic;
import com.examples.filedialog.FileDialogBasic;
import com.examples.filedialog.FileDialogSave;
import com.examples.font.FontDialogBasic;
import com.examples.font.FontEnhanced;
import com.examples.graphics.ClippingRegion;
import com.examples.graphics.GraphicsExample;
import com.examples.helloworld.DisplayBasic;
import com.examples.image.ImageBasic;
import com.examples.layouts.FillLayoutExample;
import com.examples.layouts.GridLayoutExample;
import com.examples.layouts.RowDataExample;
import com.examples.layouts.RowLayoutExample;
import com.examples.layouts.TreeItemExample;
import com.examples.layouts.TreeWithTreeItem;
import com.examples.list.ListBasic;
import com.examples.list.ListSelectionListener;
import com.examples.menu.SubMenuItem;
import com.examples.messagebox.MessageBoxBasic;
import com.examples.mouse.AllMouseEvents;
import com.examples.painting.PaintingBasic;
import com.examples.progressbar.ProgressBarBasic;
import com.examples.progressbar.ProgressBarScrolling;
import com.examples.slider.SliderEnhanced;
import com.examples.table.TableBackgroundExample;
import com.examples.traversal.CustomTraversal;

public class MasterExample {


	public static void main(String[] args) {
		
		final Display display = new Display();
		Shell shell = new Shell(display);
		
		shell.setLayout(new FillLayout());
		shell.setText("SWT examples");
		final Combo combo = new Combo(shell, SWT.DROP_DOWN | SWT.MULTI);
		combo.add("Introduction to Shell and Display", 0);
		combo.add("Composite Labels and Columns", 1);
		combo.add("Combo Box and their types", 2);
		combo.add("Key Listener in Combo Box", 3);
		combo.add("Multi Line Text example", 4);
		combo.add("Message Box example", 5);
		combo.add("Painting a Composite", 6);
		combo.add("Prompting for a String", 7);
		combo.add("Colour Dialog example", 8);
		combo.add("Control with various widgets", 9);
		combo.add("Button inside a Composite", 10);
		combo.add("Fill Layout example", 11);
		combo.add("Grid Layout example", 12);
		combo.add("Row Layout example", 13);
		combo.add("Row Data example", 14);
		combo.add("Tree & Tree Item example", 15);
		combo.add("Making Tree Item editable", 16);
		combo.add("Key board arrow key events", 17);
		combo.add("List with selectable multiple values", 18);
		combo.add("Adding selection listeners on list values", 19);
		combo.add("All Mouse Events and Listeners", 20);
		combo.add("Menus and Sub Menu example", 21);
		combo.add("Drawing Triangle with Graphics Context", 22);
		combo.add("Clipping Region with Graphics Context", 23);
		combo.add("Drawing Image with Graphics Context", 24);		
		combo.add("Painting Using Graphics Context", 25);
		combo.add("Table with Table Items example", 26);
		combo.add("Custom Traversal example", 27);
		combo.add("Coolbar and Cool Item example", 28);
		combo.add("Resizing Shells and Rectangles", 29);
		combo.add("Moving shells and rectangles", 30);
		combo.add("Open File dialog", 31);
		combo.add("Save files using File dialog", 32);
		combo.add("Changing text font and size", 33);
		combo.add("Changing label font and size", 34);
		combo.add("Redrawing while resizing", 35);
		combo.add("Progress Bar example", 36);
		combo.add("Progress Bar Scrolling example", 37);
		combo.add("Slider example with positions identified", 38);
		combo.add("Calendar Example with Mouse and Keyboard Listeners", 39);
		combo.add("Calendar Example using Items", 40);
		
		Button button = new Button(shell, SWT.PUSH);
		button.setText("Execute");
		button.addSelectionListener(new SelectionListener() {
			
			@Override
			public void widgetSelected(SelectionEvent e) {
				final int index = combo.getSelectionIndex();
				if (index == 0) {
					DisplayBasic.main(null);
				}
				if(index == 1){
					CompositeEnhanced.main(null);
				}
				if(index == 2){
					ComboBasic.main(null);
				}
				if(index == 3){
					KeyListenerInCombo.main(null);
				}
				if(index == 4){
					MultiLineText.main(null);
				}
				if(index == 5){
					MessageBoxBasic.main(null);
				}
				if(index == 6){
					PaintComposite.main(null);
				}
				if(index == 7){
					StringPrompt.main(null);
				}
				if(index == 8){
					ColourBasic.main(null);
				}
				if(index == 9){
					ControlBasic.main(null);
				}
				if(index == 10){
					EnablingBasic.main(null);
				}
				if(index == 11){
					FillLayoutExample.main(null);
				}
				if(index == 12){
					GridLayoutExample.main(null);
				}
				if(index == 13){
					RowDataExample.main(null);
				}
				if(index == 14){
					RowLayoutExample.main(null);
				}
				if(index == 15){
					TreeWithTreeItem.main(null);
				}
				if(index == 16){
					TreeItemExample.main(null);
				}
				if(index == 17){
					CustomTraversal.main(null);
				}
				if(index == 18){
					ListBasic.main(null);
				}
				if(index == 19){
					ListSelectionListener.main(null);
				}
				if(index == 20){
					AllMouseEvents.main(null);
				}
				if(index == 21){
					SubMenuItem.main(null);
				}
				if(index == 22){
					GraphicsExample.main(null);
				}
				if(index == 23){
					ClippingRegion.main(null);
				}
				if(index == 24){
					ImageBasic.main(null);
				}
				if(index == 25){
					PaintingBasic.main(null);
				}
				if(index == 26){
					TableBackgroundExample.main(null);
				}
				if(index == 27){
					CustomTraversal.main(null);
				}
				if(index == 28){
					CoolItemBasic.main(null);
				}
				if(index == 29){
					ResizeEvent.main(null);
				}
				if(index == 30){
					MoveBasic.main(null);
				}
				if(index == 31){
					FileDialogBasic.main(null);
				}
				if(index == 32){
					FileDialogSave.main(null);
				}
				if(index == 33){
					FontDialogBasic.main(null);
				}
				if(index == 34){
					FontEnhanced.main(null);
				}
				if(index == 35){
					PaintingBasic.main(null);
				}
				if(index == 36){
					ProgressBarBasic.main(null);
				}
				if(index == 37){
					ProgressBarScrolling.main(null);
				}
				if(index == 38){
					SliderEnhanced.main(null);
				}
				if(index == 39){
					CalendarView.main(null);
				}
				if(index == 40){
					CalendarMain.main(null);
				}
			}

			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
			}
		});
		
		shell.open();
		shell.pack();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
		

	}

}
